#include <iostream>
#include <set>
#include <vector>
#include <algorithm>

using namespace std;

class Solution
{
public:
    int maximumSetSize(vector<int> &nums1, vector<int> &nums2)
    {
        set<int> set1, set2;
        for (auto n : nums1)
            set1.insert(n);
        for (auto n : nums2)
            set2.insert(n);
        size_t size1 = nums1.size() / 2;
        size_t size2 = nums2.size() / 2;
        set<int> ins;
        set_intersection(set1.begin(), set1.end(), set2.begin(), set2.end(), inserter(ins, ins.begin()));
        size_t self1 = min(size1, set1.size() - ins.size());
        size_t union1 = size1 - self1;
        size_t self2 = min(size2, set2.size() - ins.size());
        size_t union2 = size2 - self2;
        size_t union12 = min(union1 + union2, ins.size());
        return self1 + self2 + union12;
    }
};

int main()
{
    cout << "Code3002" << endl;
    Solution s;
    cout << s.maximumSetSize(vector<int>{1, 2, 1, 2}, vector<int>{1, 1, 1, 1});
    return 0;
}